package com.yanqu.road.server.manager.activity.summergames;

import com.yanqu.road.entity.activity.summergames.cross.CrossSummerGamesExchangeData;

import java.util.Comparator;
import java.util.List;

public class SummerGamesExchangeSort implements Comparator<CrossSummerGamesExchangeData> {

    /**
     * 拥有的数量，从大到小的道具id
     */
    List<Integer> ownSortList;

    public SummerGamesExchangeSort(List<Integer> ownSortList) {
        this.ownSortList = ownSortList;
    }

    @Override
    public int compare(CrossSummerGamesExchangeData o1, CrossSummerGamesExchangeData o2) {
        int idx1 = ownSortList.indexOf(o1.getWantGoodsId());
        int idx2 = ownSortList.indexOf(o2.getWantGoodsId());
        if(idx1 == idx2){
            return 0;
        }
        if(idx1 == -1){
            return 1;
        }
        if(idx2 == -1){
            return -1;
        }
        return Integer.compare(idx1, idx2);
    }

}
